package com.zxz.zxzencryption.common.encryption.controller;

import com.zxz.zxzencryption.common.encryption.domain.AjaxResult;
import com.zxz.zxzencryption.tool.encryption.DesEncryptionTool;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * res加密处理
 */
@RestController
public class DesContrller {

    /**
     * @api {get} /desEncryption   des加密
     * @apiName des加密处理
     * @apiGroup Des
     * @apiDescription des加密的接口
     * @apiParam code 需要加密的内容
     * @apiParamExample {json}
     * Request-Example 1:
     * {
     *      "msg":"-9H5Sm2crvnyY-2Q8NX_ug",
     *      "code":200
     * }
     * @apiSuccess 1
     */
    @GetMapping("/desEncryption")
    public AjaxResult desEncryption(HttpServletResponse response) throws Exception
    {
        String source = "123";
        System.out.println("Excepted:" + source);

        String result = DesEncryptionTool.enCryptAndEncode(source);
        AjaxResult ajaxResult = AjaxResult.success(DesEncryptionTool.enCryptAndEncode(source));
        return ajaxResult;
    }
}
